$(function () {
    var fontSize = $$.fitFontSize(16);
    var  areacode = '330000';
    var mapAreaCode = '330000'; //区划关键点
    var commonYear = (new Date()).getFullYear();
    var areaSelectDatas = [
        { name:'浙江省',value:'330000'},
        { name:'杭州市',value:'330100'},
        { name:'宁波市',value:'330200'},
        { name:'温州市',value:'330300'},
        { name:'嘉兴市',value:'330400'},
        { name:'湖州市',value:'330500'},
        { name:'绍兴市',value:'330600'},
        { name:'金华市',value:'330700'},
        { name:'衢州市',value:'330800'},
        { name:'舟山市',value:'330900'},
        { name:'台州市',value:'331000'},
        { name:'丽水市',value:'331100'},
    ]
    layui.use('form', function(){
        var form = layui.form;
        setAreaSelects();
        form.render();
        form.on('select(areaCodeSelect)', function(data){
            areacode=data.value;
            init()
        });  
    });
    $('[page-href-tab]').click(function(){
        var src = $(this).attr('page-href-tab');
        window.parent.changeMainPage(src,true);
    })
    function setAreaSelects(){
        var html = '';
        $.each(areaSelectDatas,function(i,item){
            html += '<option value="'+item.value+'">'+item.name+'</option>'
        })
        $('[lay-filter="areaCodeSelect"]').html(html)
    }
    //总体概况
    init()
    function init(){//TODO: 首页
        getqyzs()//企业总数
        getdjfbqk()//用工单位信用等级分布情况
        getjyndwqk()//近1年用工单位被投诉情况
         getxyda()  //信用档案
         getssjyy()//双随机应用
         gethmdZb()//黑名单
        getsdqy()//三多企业
        getxypjdjqs()//信用评价等级趋势
        getlhcj() //11.联合惩戒
        getczjsltj()//初中级数量统计
        getgjsltj()//高级数量统计
       getsblyyzsxrymd() //社保领域严重失信人名单
       getldbzjc()//劳动保障监察
       getgsxbjsl()//各事项办件的数量（、出具征信意见书数量查询）
       getgjjgyx()//高级技工院校设立
      getzcjsry() //专业技术人员资格考试证书
      getzdfxrq()  //重点风险人群、重点关怀人群
      getkswjsl()//1. 考试违纪数量
      getxydagr()//信用档案个人
    }
    function getxydagr(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/getLaborNum',{
            year:commonYear,
            aab301:areacode
        },function (res) {
            var data={
                value:res.data
            }
            setZBData(".xydagr",data,function(){
                $(".xydagr [data-key]").on("click",function(){
                    alertZBGRtable("个人")
                })
            })
        })
    }
    function alertZBGRtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "姓名", field: "realName"},
                {title: "身份证", field: "idCardNo"},
                {title: "手机号", field: "mobilephone"},
                {title: "在职情况", field: "isJob"},
                {title: "工种", field: "worktypeName"},
                {title: "有无不良行为", field: "badStatus"},
               {title: "所属企业", field: "currentCompanyName"},
               {title: "所属工程项目", field: "currentProjectName"}
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/getLaborList',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBGRDetails(obj)
            }
        });
    
    }
    function alertZBGRDetails(obj){
        var tableColumns = [
            [
                {title: "姓名", field: "realName"},
                {title: "性别", field: "gender"},
                {title: "籍贯编号", field: "nativeplaceId"},
                {title: "民族编号", field: "nationId"},
               {title: "生日", field: "birthday"},
               {title: "身份证", field: "idCardNo"},
               {title: "手机号", field: "mobilephone"},
               {title: "家庭住址", field: "address"},
            //    {title: "银行名称", field: "bankName"},
            //    {title: "银行卡号", field: "bankNo"}
            ]
        ];
        var ecm = $$.alert('axzs');
        $('#' + ecm).html(`
            <div class="title">详情</div>
            <div class="table_con">
                <div class="model">
                    <div class="model_title">基本信息</div>
                    <div class="model_content jbxxBox">
                    <div class="imgBox"><img src="" alt=""></div>
                    <div class="ztxxTable"></div>
                    </div>
                </div>
                <div class="model">
                <div class="model_title">履历轨迹</div>
                <div class="model_content" id="table${ecm}">
                <div  class="news newsTable" >
                </div>
                <div class="pagenation"></div>
                </div>
                 </div>
                <div class="model">
                <div class="model_title">劳动纠纷案件列表</div>
                <div class="model_content" id="table1${ecm}">
                <div  class="news newsTable" >
                </div>
                <div class="pagenation"></div>
                </div>
                </div>
                
            </div>
               
            </div>
        `);
        $$.ajaxRequest(ajaxUrl + '/zjax/admin/sbjg/getLaborInfo',{
            lid: obj.data.lid,
            year:commonYear,
            aab301:mapAreaCode
        },function(res){
            var data = res.data ||　{};
            $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
            $(".imgBox img").attr("src",data.userPhoto||'')
            gettablePhb({
                tableId:`#table${ecm}`,
                autoScroll: false,
                time: 2500,
                imgIndex: false,
                scrollName: "",
                columns: [
                    {title: "所属区域",field: "area"},	
                    {title: "所属企业",field: "currentCompanyName"},	 
                    {title: "所属项目",field: "sourceProjectName"},   
                    {title: "入职时间",field: "starttime"}, 	
                    {title: "工种编号",field: "worktypeNo"},	
                    {title: "工种名称",field: "worktypeName"}
                ],
                data:data.labourerResumes
            })
            gettablePhb({
                tableId:`#table1${ecm}`,
                autoScroll: false,
                time: 2500,
                imgIndex: false,
                scrollName: "",
                columns: [
                    {title: "案件编号",field: "abb016"},	
                    {title: "办件状态",field: "bfd194"},	 
                    {title: "申请人",field:	"abb703"},   
                    {title: "被申请人",field: "abb704"}, 	
                    {title: "受理时间",field: "abb013"},	
                    {title: "案由类型",field: "bae213"},   
                    {title: "地区",field: "aab301"},	
                    {title: "涉及人数(人)",field: "abb722"},	
                    {title: "涉及金额(元)",field: "bfd024"},	
                    {title: "结案处置方式",field: "abd001"},	
                    {title: "结果类型",field: "bfd208"},	
                    {title: "结案时间",field: "abb023"},	
                    {title: "经办人",field: "aae011"},
                ],
                data:res.ldjf
            })
        });
        function gettablePhb(config) {
            var id = config.tableId || ''
            var columns = config.columns || []
            var datas = config.data || [];
            config.showPageNumber=config.showPageNumber||true
            var scrollName = config.scrollName;
            if(datas && datas.length>0){
                var html = '<div class="tbody"></div>';
                var head_html_ = `<div class="thead"><div class="t_tr">`
                $.each(columns, function (i, item) {
                    head_html_ += '<div class="text_overflow" style="width:' + (item.width || 'calc(100% / ' + columns.length + ')') + '" title="' + item.title + '">' + (item.title) + '</div>'
                })
                head_html_ += ` </div></div>`
                var pageHTML='',pageSize= config.pageSize||2,
                pages = Math.ceil(datas.length/pageSize),pageIndex=0;
            datas = datas.map((item,i)=>{
                item.pm = i+1;
                return item;
            })
            while(pages>0){
                pageIndex++;
                pageHTML += '<div class="'+(config.showPageNumber?'page_num':'')+'">'+(config.showPageNumber?pageIndex:'')+'</div>';
                pages--;
            };
            if(pageIndex>1){
                $(id+' .pagenation').html(pageHTML);
                $(id+' .pagenation div').eq(0).addClass('active');
                $(id+' .pagenation div').click(function(){
                    var index = $(this).index();
                    setData(index);
                    $(this).addClass('active').siblings().removeClass('active');
                });
                }
            }
            if (datas.length > 0) {
                $(id +" .news").html(head_html_ + html);
            } else {
                $(id +" .news").html(`<div style=" text-align: center;">暂无数据</div>`);
            }
            setData(0)
            function setData(pageIndex){
                var dataHTML = '';
                var i = 0;
                var data = datas.slice(pageIndex*pageSize,(pageIndex+1)*pageSize);
                while(i<pageSize && i<data.length){
                    dataHTML += '<div class="tr  t_tr text_overflow">'
                    $.each(columns,function(colIndex,colItem){
                        dataHTML += '<div class="text_overflow" style="width:'+(colItem.width||'calc(100% / '+columns.length+')')+'">'+(data[i][colItem.field])+'</div>';
                    })
                    dataHTML += '</div>';
                    // dataHTML += '<div class="item text_overflow pm_'+(data[i].pm)+'"><div class="pm_box"><span>TOP '+(moreThanTen(data[i].pm||1))+'</span></div>'+(data[i].gz_value||0)+'</div>';
                    i++;
                };
                    $(id+' .tbody').html(dataHTML);
                 }
               
            
            // if (config.autoScroll) {
            //     console.log(config.time, "config.time",)
            //     clearInterval(scrollName)
            //     scrollName = $(id + ' .tbody').scrollTable2({
            //         interval: config.time,
            //         scrollByRow: true,
            //     })
            // }
        }
    }
    function getkswjsl(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/kswjNum',{
            year:commonYear,
            aab301:areacode
        },function (res) {
            var data={
                value:res.data
            }
            setZBData(".kswjZB",data,function(){
                $(".kswjZB [data-key]").on("click",function(){
                    alertZBWJKStable("考试违纪信息")
                })
            })
        })
    }
    function alertZBWJKStable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "姓名", field: "xm"},
                {title: "身份证号", field: "sfzh"},
                {title: "考试名称", field: "ksmc"},
                {title: "准考证号", field: "zkzh"},
                {title: "工作单位", field: "gzdw"},
                {title: "决定时间", field: "sjdsj"},
                {title: "文号", field: "wh"},
                {title: "处理意见", field: "clyj"},
                {title: "违纪行为", field: "wjxw"}
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/kswjPage',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
               
            }
        });
    
        }
      
    function getzdfxrq(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/zdfxghry',{
            year:commonYear,
            aab301:areacode
        },function (res) {
            setZBData(".zdrqZB",res.data,function(){
                $(".zdrqZB [data-key]").on("click",function(){
                    var type=$(this).attr("data-key")
                    if(type=="zdfxnum"){
                        alertZBFXtable("重点风险人群",1)
                    }else if(type=="zdghnum"){
                        alertZBFXtable("重点关怀人群",2)     
                    }


                })
            })
        })
    }
    function getgjjgyx(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/xyxt/queryXySxNum?sxlx=01&zhuxbm=00118&zhixbm=001',{
            xzqh:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".gjyxZb",res.data,function(){
                $(".gjyxZb [data-key]").on("click",function(){
                    alertZBGXtable("高级技工院校设立审批")
                })
            })
        })
    }
    
 function alertZBGXtable(title){
    $$.alertTable({
        title: title+'  ',
        colsData: [[
            { type: 'numbers', title: '序号' },
            {title: "申报号", field: "sbh"},
            {title: "申报时间", field: "sbsj"},
            {title: "单位名称名称", field: "applyname"},
            {title: "办件来源", field: "bjly_text"},
            {title: "统一社会信用代码", field: "apply_cardnumber"},
            {title: "申报来源", field: "bjly_text"},
        {title: "事项名称", field: "qlsxmc"},
        {title: "是否是告知承诺", field: "is_promise_text"},
        {title: "受理时间", field: "slsj"},
        {title: "办结时间", field: "bjsj"},
        ]],
        url: ajaxUrl + '/zjax/admin/xyxt/queryXySxList?sxlx=01&zhuxbm=00118&zhixbm=001',
        where: {
            year:commonYear,
            aab301:mapAreaCode
        },
        pageProp: {
            limit: 10
        },
        rowClickFun: function (obj) {
           
        }
    });

}
    function  getgsxbjsl(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/xyxt/queryXySxNum?sxlx=10&zhuxbm=02121&zhixbm=001',{
            xzqh:areacode,
            year:commonYear
        },function (res) {
            setZBData(".sblyyzrymdZb",res.data,function(){
                $(".sblyyzrymdZb [data-key]").on("click",function(){
                    alertZBYJStable("出具征信意见书")
                })
            })
        })
    }
    
 function alertZBYJStable(title){
    $$.alertTable({
        title: title+'  ',
        colsData: [[
            { type: 'numbers', title: '序号' },
            {title: "申报号", field: "sbh"},
            {title: "申报时间", field: "sbsj"},
            {title: "单位名称名称", field: "applyname"},
            {title: "办件来源", field: "bjly_text"},
            {title: "统一社会信用代码", field: "apply_cardnumber"},
            {title: "申报来源", field: "bjly_text"},
        {title: "事项名称", field: "qlsxmc"},
        {title: "是否是告知承诺", field: "is_promise_text"},
        {title: "受理时间", field: "slsj"},
        {title: "办结时间", field: "bjsj"},
        ]],
        url: ajaxUrl + '/zjax/admin/xyxt/queryXySxList?sxlx=10&zhuxbm=02121&zhixbm=001',
        where: {
            year:commonYear,
            aab301:mapAreaCode
        },
        pageProp: {
            limit: 10
        },
        rowClickFun: function (obj) {
           
        }
    });

}
    function getldbzjc(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/xyxt/queryZxyjListByMonth?sxlx=10&zhuxbm=02121&zhixbm=001',{
            xzqh:areacode,
            year:commonYear
        },function (res) {
            var data=res.data
            setLine('#ldbzjcLine',{
                unit:'件',
                "categories":data.map(item => item.month),
                "series":[
                    {"name":"征信意见书查询次数","data":data.map(item => item.num)},
                    // {"name":"2021年","data":[7,15,14,13,15,18]}
                ]
            },{color:["#34C39D"],hideArea:true})
        })
      
    }
  
    function getsblyyzsxrymd(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/yzsxmd',{
            year:commonYear,
            aab301:areacode
        },function (res) {
            setZBData(".sblyyzrymd",res.data)
        })
    }
    function getzcjsry(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/zgkszsNum',{
            year:commonYear,
            aab301:areacode,
            pageIndex:0,
            pageSize:10
        },function (res) {
            var data={
                value:res.data
            }
            setZBData(".zyryZb",data,function(){
                $(".zyryZb [data-key]").on("click",function(){
                    alertZBZYRYtable("专业技术人员资格考试证书")
                })
            })
        }) 
    }
    function alertZBZYRYtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "考生姓名", field: "ksxm_1"},
                {title: "证件号码", field: "zjhm"},
                {title: "报考专业名称", field: "bkzymc"},
                {title: "报考级别名称", field: "bkjbmc"},
                {title: "有效期起始时间", field: "yxqqs"},
                {title: "发证单位", field: "fzdw"},
                {title: "证照编号", field: "zzbh"},
                {title: "考试时间", field: "kssj;"},
                {title: "考试科目", field: "kskm"},
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/zgkszsPage',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
               
            }
        });
    
   }

    function getgjsltj(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/gjzsNum',{
            year:commonYear,
            aab301:areacode,
            pageIndex:0,
            pageSize:10
        },function (res) {
            var data={
                value:res.data
            }
            setZBData(".gjryZb",data,function(){
                $(".gjryZb [data-key]").on("click",function(){
                    alertZBGJZStable("高级专业技术职务任职资格证书")
                })
            })
        })
    }
    function alertZBGJZStable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "姓名", field: "xm"},
                {title: "出生年月", field: "csny"},
                {title: "专业名称", field: "zymc"},
                {title: "级别名称", field: "jbmc"},
                {title: "取得资格时间", field: "qdzgsj"},
                {title: "发证单位", field: "fzdw"},
                {title: "证件号码", field: "zjhm"},
                {title: "发证时间", field: "fzsj"},
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/gjzsPage',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
               
            }
        });
    
   }
    function getczjsltj(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/czjzsNum',{
            aab301:areacode,
            year:commonYear,
            pageIndex:0,
            pageSize:10
        },function (res) {
            var data={
                value:res.data
            }
            setZBData(".czjzyzs",data,function(){
                $(".czjzyzs [data-key]").on("click",function(){
                    alertZBCZJStable("初中级专业技术职务任职资格证书")
                })
            })
        })
    }
    function alertZBCZJStable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "姓名", field: "xm"},
                {title: "出生年月", field: "csny"},
                {title: "专业名称", field: "zymc"},
                {title: "级别名称", field: "jbmc"},
                {title: "取得资格时间", field: "qdzgsj"},
                {title: "发证单位", field: "fzdw"},
                {title: "证件号码", field: "zjhm"},
                {title: "发证时间", field: "fzsj"},
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/czjzsPage',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
               
            }
        });
    
   }
    function  getlhcj(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/zjax/zdwfxwNum',{
            year:commonYear,
            aab301:areacode
        },function (res) {
            console.log(res.data,"res.data")
            setZBData(".lhcjZb",res.data,function(){
                $(".lhcjZb [data-key]").on("click",function(){
                    var type=$(this).attr("data-key")
                    if(type=="wfxwnum"){
                        alertZBZDXWtable("重大违法行为")
                    }else if(type=="grhmd"){
                        alertZBHNGRtable("个人","02")
                    }else if(type=="hmdnum"){
                        alertZBHNGRtable("企业","01")
                    }
                })
            })
        })
    }
    function alertZBZDXWtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                {title: "单位名称", field: "aab004"},
                {title: "统一社会信用代码", field: "aab003"},
                {title: "法定代表人", field: "aab013"},
                { title: '公开日期', field: 'gbsj'},
                { title: '所属管辖', field: 'aab301'},
                {title: "地址", field: "aae006"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/zdwfxwList',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBZDXWDetails(obj);//taskId 主键
            }
        });
    
        }
        function alertZBZDXWDetails(obj){
            var tableColumns = [
                [
                    {title: "单位名称", field: "aab004",fitWidth:true},
                    {title: "统一社会信用代码", field: "aab003",fitWidth:true},
                    {title: "法定代表人", field: "aab013"},
                    {title: "公开时间", field: "gbsj"},
                    {title: "违法行为", field: "abc001",fitWidth:true},
                    {title: "处罚内容", field: "abc002",fitWidth:true},
                    {title: "地址", field: "aae006",fitWidth:true}
                ]
            ];
            var ecm = $$.alert('axzs');
            $('#' + ecm).html(`
                <div class="title">详情</div>
                <div class="table_con">
                    <div class="model">
                        <div class="model_title">基本信息</div>
                        <div class="model_content ztxxTable"></div>
                    </div>
                   
                </div>
            `);
            
            $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/zdwfxwDetail',{
                id: obj.data.id,
                year:commonYear,
                aab301:mapAreaCode
            },function(res){
                var data = res.data ||　{};
                $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
              
            });
        }
    function alertZBHNGRtable(title,dxlx){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "文书号", field: "wsh"},
                {title: "对象名称", field: "aab004"},
                {title: "统一社会信用代码", field: "aab003"},
                {title: "列入时间", field: "lrsj"},
                {title: "所属管辖", field: "aab301"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/qyhmdList',
            where: {
                dxlx:dxlx||"",
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBHMGRDetails(obj);//taskId 主键
            }
        });
    
        }
        function alertZBHMGRDetails(obj){
            var tableColumns = [
                [
                    {title: "发布机关", field: "fbjg"},
                    {title: "文书号", field: "wsh"},
                    {title: "单位名称", field: "aab004"},
                    {title: "统一社会信用代码", field: "aab003"},
                    {title: "法定代表人", field: "aab013"},
                    {title: "法定代表人身份证", field: "aac002"},
                    {title: "列入时间", field: "lrsj"},
                    {title: "涉及金额", field: "sjje"},
                    {title: "列入原因", field: "abb012",fitWidth:true},
                    {title: "列入依据", field: "lryj",fitWidth:true},
                    {title: "预计退出日期", field: "fbqx"},
                    {title: "认定时间", field: "rdsj"},
                    {title: "认定单位统一社会信用代码", field: "rddwtyshxydm"},
                    {title: "当前状态", field: "tcqk"},
                    {title: "到期退出情况", field: "dqtcqk",fitWidth:true},
                    {title: "续期原因", field: "xqyy",fitWidth:true}
                ]
            ];
            var ecm = $$.alert('axzs');
            $('#' + ecm).html(`
                <div class="title">详情</div>
                <div class="table_con">
                    <div class="model">
                        <div class="model_title">基本信息</div>
                        <div class="model_content ztxxTable"></div>
                    </div>
                   
                </div>
            `);
            
            $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/qyhmdDetail',{
                tongid: obj.data.tongid,
                year:commonYear,
                aab301:mapAreaCode
            },function(res){
                var data = res.data ||　{};
                $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
              
            });
        }
    function getxypjdjqs(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/ssjXyTrend',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            var data=res.data
            console.log(data.map(item => item.name))
            setLine('#ldbzxypjdjLine',{
                unit:'件',
                "categories":data.map(item => item.name),
                "series":[
                    {"name":"A","data":data.map(item => item.a)},
                     {"name":"B","data":data.map(item => item.b)},
                     {"name":"C","data":data.map(item => item.c)},
                     {"name":"D","data":data.map(item => item.d)},
                     {"name":"E","data":data.map(item => item.e)},
                ]
            },{color:["#00EB53","#34C39D","#15C0FF","#FFBD1E","#FF4E4E"],hideArea:true})
        })
    }
    function getsdqy(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/sdqyTj',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            var data=res.data
            setBar("#sdqyBar",{
                unit:'件',
                "categories":data.map(item => item.name),
                "series":[
                    {"name":"","data":data.map(item => item.value)},
                    // {"name":"2021年","data":[7,15,14,13,15,18]}
                ]
            },{color:[{color1:"#2F9EFE",color2:"#2F9EFE"}]})
        })
       
    }
    function gethmdZb(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/ssjHmdNum',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".hmd",res.data)
        })
    }
    function  getssjyy(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/zjax/netRegulation',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".ssjyy",res.data,function(){
                $(".ssjyy").on("click",function(){
                    alertZBSJYYStable("双随机应用")
                })
            })
        })
    }
    function alertZBSJYYStable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { title: '序号', type: 'numbers' },
                // {title: "任务来源名称", field: "taskSourceName"},
                // {title: "检查对象名称", field: "legalEntityname"},
                {title: "统一社会信用代码", field: "unicode"},
                {title: "任务编码", field: "taskcode"},
                {title: "创建时间", field: "createtime"},
                {title: "检查完成时间", field: "checkcompletetime"},
                {title: "检查人员", field: "supervisorname"},
                {title: "检查部门", field: "deptname"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/ssjTaskList',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBSJYYSDetails(obj)
            }
        });
       }
       function alertZBSJYYSDetails(obj){
        var tableColumns = [
            [
                {title: "任务类型", field: "tasktype"},
                // {title: "任务来源名称", field: "tasksourcename"},
                {title: "任务编码", field: "taskcode"},
                {title: "创建时间", field: "createtime"},
                {title: "计划完成时间", field: "plancompletetime"},
                {title: "检查完成时间", field: "checkcompletetime"},
                {title: "检查对象名称", field: "legalentityname"},
                {title: "统一社会信用代码", field: "unicode"},
                {title: "检查部门", field: "deptname"},
                {title: "部门编码", field: "deptuniquecode"},
                {title: "任务状态", field: "taskstatus"},
                {title: "任务录入人", field: "setusername"},
                {title: "查无下落原因", field: "checknowhereaboutsreason"},
            ]
        ];
        var ecm = $$.alert('axzs');
        $('#' + ecm).html(`
            <div class="title">详情</div>
            <div class="table_con">
                <div class="model">
                    <div class="model_title">基本信息</div>
                    <div class="model_content ztxxTable"></div>
                </div>
               
            </div>
        `);
        
        $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/ssjTaskDetail',{
            taskid: obj.data.taskid,
            year:commonYear,
            aab301:mapAreaCode
        },function(res){
            var data = res.data ||　{};
            $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
          
        });
       }
    function getxyda(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/zjax/keyMonitor',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".xydaZB",res.data,function(){
                $(".xydaZB [data-key]").on("click",function(){
                    var type=$(this).attr("data-key")
                     if(type=="zdjkqy"){
                        alertZBQYJKtable("重点监控企业")
                     }else if(type=="zdjkry"){
                        alertZBRYtable("重点服务人群")
                     }
                    

                })
            })
        })
    }
    function alertZBFXtable(title,type){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { title: '序号', type: 'numbers' },
                {title: "姓名", field: "name"},
                {title: "身份证号", field: "zjhm"},
                {title: "人员类别", field: "ry_type"},
                {title: "人员性质", field: "ryxz"},
                {title: "参与项目", field: "cyxm"}
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/zdfxghryList',
            where: {
                type:type||"",
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
               // alertZBFXDetails(obj);//taskId 主键
            }
        });
    
        }
        function alertZBFXDetails(obj){
            var tableColumns = [
                [
                    {title: "姓名", field: "name"},
                    {title: "身份证号", field: "zjhm"},
                    {title: "人员类别", field: "ry_type"},
                    {title: "人员性质", field: "ryxz"},
                    {title: "参与项目", field: "cyxm"}
                ]
            ];
            var ecm = $$.alert('axzs');
            $('#' + ecm).html(`
                <div class="title">详情</div>
                <div class="table_con">
                    <div class="model">
                        <div class="model_title">基本信息</div>
                        <div class="model_content ztxxTable"></div>
                    </div>
                   
                </div>
            `);
            
            $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/zdryDetail',{
                id: obj.data.id,
                year:commonYear,
                aab301:mapAreaCode
            },function(res){
                var data = res.data ||　{};
                $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
              
            });
        }
    function alertZBRYtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { title: '序号', type: 'numbers' },
                {title: "姓名", field: "aac003"},
                {title: "身份证号", field: "aac002"},
                {title: "情节分类", field: "qjfl"},
                {title: "登记日期", field: "aae036"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/zdryList',
            where: {
                type:"",
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBRYDetails(obj);//taskId 主键
            }
        });
    
        }
        function alertZBRYDetails(obj){
            var tableColumns = [
                [
                    {title: "姓名", field: "aac003"},
                    {title: "身份证号", field: "aac002"},
                    {title: "联系方式", field: "tel"},
                    {title: "所在单位/项目", field: "aab004"},
                    {title: "登记日期", field: "aae036"},
                    {title: "所属管辖", field: "aab301"},
                    {title: "情形", field: "xq",fitWidth:true},
                ]
            ];
            var ecm = $$.alert('axzs');
            $('#' + ecm).html(`
                <div class="title">详情</div>
                <div class="table_con">
                    <div class="model">
                        <div class="model_title">基本信息</div>
                        <div class="model_content ztxxTable"></div>
                    </div>
                   
                </div>
            `);
            
            $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/zdryDetail',{
                id: obj.data.id,
                year:commonYear,
                aab301:mapAreaCode
            },function(res){
                var data = res.data ||　{};
                $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
              
            });
        }
    function alertZBQYJKtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "单位名称", field: "name"},
                {title: "统一社会信用代码", field: "tyshxydm"},
                {title: "所属管辖", field: "aab301"},
                {title: "信用得分", field: "score"},
                {title: "信用等级", field: "xylevel"},
                {title: "扣分说明", field: "pjreason"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/creditQyList',
            where: {
                level:"DE",
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBQYJKDetails(obj);//taskId 主键
            }
        });
    
        }
        function alertZBQYJKDetails(obj){
            var tableColumns = [
                [
                    {title: "单位名称", field: "name"},
                    {title: "统一社会信用代码", field: "tyshxydm"},
                    {title: "法定代表人", field: "aab013"},
                    {title: "所属管辖", field: "aab301"},
                    {title: "注册地址", field: "aab507"},
                    {title: "实际经营地", field: "aae006"},
                    {title: "用工状态", field: "aae119"},
                    {title: "信用得分", field: "score"},
                    {title: "信用等级", field: "xylevel"},
                    {title: "扣分说明", field: "pjreason",fitWidth:true}
                ]
            ];
            var ecm = $$.alert('axzs');
            $('#' + ecm).html(`
                <div class="title">详情</div>
                <div class="table_con">
                    <div class="model">
                        <div class="model_title">基本信息</div>
                        <div class="model_content ztxxTable"></div>
                    </div>
                   
                </div>
            `);
            
            $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/creditDetail',{
                id: obj.data.id,
                year:commonYear,
                aab301:mapAreaCode
            },function(res){
                var data = res.data ||　{};
                $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
              
            });
        }
    function getjyndwqk(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/sbjg/dwBtsqktj',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            var data=res.data
            setPie('#cyrynlPei',{datas:data,unit:"家"},{
                showValue:true,
                showPercent:false,
                legendTop:"70%",
                legendItemGap:$$.transVHFontSize(.8),
                center:['50%', '35%'],
                legendLeft:"30%",
                radius: ['35%', '52%'],
                radius2:["35%","38%"]
            },function(params){
                var index = res.data.map(item=>item.name).indexOf(params.name)
                alertZBTStable(params.name,res.data[index].code)
            });
        })
    }
    function alertZBTStable(title,num){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "单位名称", field: "aab004"},
                {title: "统一社会信用代码", field: "aab003"},
                {title: "实际经营地址", field: "bae198"},
                {title: "登记类型", field: "aab019"},
                {title: "涉案数", field: "num"},
            ]],
            url: ajaxUrl + '/zjax/admin/sbjg/ldjfqyList',
            where: {
                num:num||"",
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBSAStable(title,obj)
            }
        });
    }
    function  alertZBSAStable(title,obj){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { title: '序号', type: 'numbers' },
                {title: "案件编号",field: "abb016"},	
                {title: "办件状态",field: "bfd194"},	 
                {title: "申请人",field:	"abb703"},   
                {title: "被申请人",field: "abb704"}, 	
                {title: "受理时间",field: "abb013"},	
                {title: "诉求分类",field: "bae213"},   
                {title: "地区",field: "aab301"},	
                {title: "涉及人数(人)",field: "abb722"},	
                {title: "涉及金额(元)",field: "bfd024"},	
                {title: "结案处置方式",field: "abd001"},	
                {title: "结果类型",field: "bfd208"},	
                {title: "结案时间",field: "abb023"},	
                {title: "经办人",field: "aae011"},
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/queryldjfList?',
            where: {
                abb704:obj.data.aab004,
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
              
            }
        });
    }
    function getdjfbqk(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/zjax/creditManage',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".djqkZB",res.data,function(){
                $(".djqkZB [data-key]").on("click",function(){
                    var type=$(this).attr("data-key")
                    var level=""
                    if(type=="a"){
                        level="A"
                    }else if(type=="b"){
                        level="B"
                    }else if(type=="c"){
                        level="C"
                    }else if(type=="d"){
                        level="D"
                    }else if(type=="e"){
                        level="E"
                    }
                    alertZBPJDJtable("信用评价情况",level)
                })
            })
        })
    }
    function alertZBPJDJtable(title,level){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "单位名称", field: "name"},
                {title: "统一社会信用代码", field: "tyshxydm"},
                {title: "所属管辖", field: "aab301"},
                {title: "信用得分", field: "score"},
                {title: "信用等级", field: "xylevel"},
                {title: "扣分说明", field: "pjreason"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/creditQyList',
            where: {
                aab301: mapAreaCode,
                year: commonYear,
               level:level||''
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBPJDJDetails(obj)
            }
        });
    }
    function alertZBPJDJDetails(obj){
        var tableColumns = [
            [
                {title: "单位名称", field: "name"},
                {title: "统一社会信用代码", field: "tyshxydm"},
                {title: "法定代表人", field: "aab013"},
                {title: "所属管辖", field: "aab301"},
                {title: "注册地址", field: "aab507"},
                {title: "实际经营地", field: "aae006"},
                {title: "用工状态", field: "aae119"},
                {title: "信用得分", field: "score"},
                {title: "信用等级", field: "xylevel"},
                {title: "扣分说明", field: "pjreason",fitWidth:true}
            ]
        ];
        var ecm = $$.alert('axzs');
        $('#' + ecm).html(`
            <div class="title">详情</div>
            <div class="table_con">
                <div class="model">
                    <div class="model_title">基本信息</div>
                    <div class="model_content ztxxTable"></div>
                </div>
               
            </div>
        `);
        
        $$.ajaxRequest(ajaxUrl + '/zjax/admin/zjax/creditDetail',{
            id: obj.data.id,
            year:commonYear,
            aab301:mapAreaCode
        },function(res){
            var data = res.data ||　{};
            $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
          
        });
    }
    function getqyzs(){
        $$.ajaxRequest(ajaxUrl +'/zjax/admin/zjax/companyNum',{
            aab301:areacode,
            year:commonYear,
        },function (res) {
            setZBData(".qyzs",res.data,function(){
                  $(".qyzs").on("click",function(){
                    alertZBQYtable("企业")
                  }) 
            })
        })
    }
    function alertZBQYtable(title){
        $$.alertTable({
            title: title+'  ',
            colsData: [[
                { type: 'numbers', title: '序号' },
                {title: "单位名称", field: "name"},
                {title: "统一社会信用代码", field: "tyshxydm"},
                {title: "所属管辖", field: "aab301"},
                {title: "信用得分", field: "score"},
                {title: "信用等级", field: "xylevel"},
                {title: "扣分说明", field: "pjreason"}
            ]],
            url: ajaxUrl + '/zjax/admin/zjax/creditQyList',
            where: {
                year:commonYear,
                aab301:mapAreaCode
            },
            pageProp: {
                limit: 10
            },
            rowClickFun: function (obj) {
                alertZBQYDetails(obj)
            }
        });
    }
    function alertZBQYDetails(obj){
        var tableColumns = [
            [
                {title: "单位名称", field: "name"},
                {title: "统一社会信用代码", field: "tyshxydm"},
                {title: "法定代表人", field: "aab013"},
                {title: "所属管辖", field: "aab301"},
                {title: "注册地址", field: "aab507"},
                {title: "实际经营地", field: "aae006"},
                {title: "用工状态", field: "aae119"},
                {title: "信用得分", field: "score"},
                {title: "信用等级", field: "xylevel"},
                {title: "扣分说明", field: "pjreason",fitWidth:true}
            ]
        ];
        var ecm = $$.alert('axzs');
        $('#' + ecm).html(`
            <div class="title">详情</div>
            <div class="table_con">
                <div class="model">
                    <div class="model_title">基本信息</div>
                    <div class="model_content jbxxBox">
                    <div class="imgBox"><img src="" alt=""></div>
                    <div class="ztxxTable"></div>
                    </div>
                </div>
                <div class="model">
                <div class="model_title">劳动纠纷案件列表</div>
                <div class="model_content" id="table${ecm}">
                <div  class="news newsTable" >
                </div>
                <div class="pagenation"></div>
                </div>
                </div>
                <div class="model">
                <div class="model_title">劳动纠纷案件列表</div>
                <div class="model_content" id="table${ecm}">
                <div  class="news newsTable" >
                </div>
                <div class="pagenation"></div>
                </div>
                </div>
            </div>
               
            </div>
        `);
        $$.ajaxRequest(ajaxUrl + '/zjax/admin/sbjg/qyxydaDetail',{
            id: obj.data.id,
            year:commonYear,
            aab301:mapAreaCode
        },function(res){
            var data = res.data ||　{};
            $$.title2Table('#'+ecm+' .ztxxTable',tableColumns[0], data||{},2);
            $(".imgBox img").attr("src",data.userPhoto||'')
            gettablePhb({
                tableId:`#table${ecm}`,
                autoScroll: false,
                time: 2500,
                imgIndex: false,
                scrollName: "",
                columns: [
                    {title: "案件编号",field: "abb016"},	
                    {title: "办件状态",field: "bfd194"},	 
                    {title: "申请人",field:	"abb703"},   
                    {title: "被申请人",field: "abb704"}, 	
                    {title: "受理时间",field: "abb013"},	
                    {title: "案由类型",field: "bae213"},   
                    {title: "地区",field: "aab301"},	
                    {title: "涉及人数(人)",field: "abb722"},	
                    {title: "涉及金额(元)",field: "bfd024"},	
                    {title: "结案处置方式",field: "abd001"},	
                    {title: "结果类型",field: "bfd208"},	
                    {title: "结案时间",field: "abb023"},	
                    {title: "经办人",field: "aae011"},
                ],
                data:data.ldjf
            })
        });
       
    }
    function gettablePhb(config) {
        var id = config.tableId || ''
        var columns = config.columns || []
        var datas = config.data || [];
        config.showPageNumber=config.showPageNumber||true
        var scrollName = config.scrollName;
        if(datas && datas.length>0){
            var html = '<div class="tbody"></div>';
            var head_html_ = `<div class="thead"><div class="t_tr">`
            $.each(columns, function (i, item) {
                head_html_ += '<div class="text_overflow" style="width:' + (item.width || 'calc(100% / ' + columns.length + ')') + '" title="' + item.title + '">' + (item.title) + '</div>'
            })
            head_html_ += ` </div></div>`
            var pageHTML='',pageSize= config.pageSize||2,
            pages = Math.ceil(datas.length/pageSize),pageIndex=0;
        datas = datas.map((item,i)=>{
            item.pm = i+1;
            return item;
        })
        while(pages>0){
            pageIndex++;
            pageHTML += '<div class="'+(config.showPageNumber?'page_num':'')+'">'+(config.showPageNumber?pageIndex:'')+'</div>';
            pages--;
        };
        $(id+' .pagenation').html(pageHTML);
        $(id+' .pagenation div').eq(0).addClass('active');
        $(id+' .pagenation div').click(function(){
            var index = $(this).index();
            setData(index);
            $(this).addClass('active').siblings().removeClass('active');
        });
        }
       
        if (datas.length > 0) {
            $(id +" .news").html(head_html_ + html);
        } else {
            $(id +" .news").html(`<div style=" text-align: center;">暂无数据</div>`);
        }
        setData(0)
        function setData(pageIndex){
            var dataHTML = '';
            var i = 0;
            var data = datas.slice(pageIndex*pageSize,(pageIndex+1)*pageSize);
            while(i<pageSize && i<data.length){
                dataHTML += '<div class="tr  t_tr text_overflow">'
                $.each(columns,function(colIndex,colItem){
                    dataHTML += '<div class="text_overflow" style="width:'+(colItem.width||'calc(100% / '+columns.length+')')+'">'+(data[i][colItem.field])+'</div>';
                })
                dataHTML += '</div>';
                // dataHTML += '<div class="item text_overflow pm_'+(data[i].pm)+'"><div class="pm_box"><span>TOP '+(moreThanTen(data[i].pm||1))+'</span></div>'+(data[i].gz_value||0)+'</div>';
                i++;
            };
                $(id+' .tbody').html(dataHTML);
             }
           
        
        // if (config.autoScroll) {
        //     console.log(config.time, "config.time",)
        //     clearInterval(scrollName)
        //     scrollName = $(id + ' .tbody').scrollTable2({
        //         interval: config.time,
        //         scrollByRow: true,
        //     })
        // }
    }
  function PercentCircle(id,data,options){
    var elem = $(id)[0];
    var radius =options.radius||['60%', '70%']
    var fontSize=options.fontSize||20
    var title=data.value+data.unit;
    var colors=options.colors||{color1:'#FFBE4E',color2:'#FF9A37'}
    var myChart = echarts.init(elem);
    var myOption = {
        title: {
            text: title,
            x: 'center',
            y: 'center',
            textStyle: {
                fontWeight: 'normal',
                color: '#fff',
                fontSize:fontSize
            }
        },
        color: ['#282c40'],
        legend: {
            show: true,
            data: []
        },
        series: [{
            name: 'percent',
            type: 'pie',
            clockWise: true,
            radius: radius,
            center:['50%','50%'],
            itemStyle: {
                normal: {
                    label: {
                        show: false
                    },
                    labelLine: {
                        show: false
                    }
                }
            },
            hoverAnimation: false,
            data:[
                {
                    value:data.value-0,
                    name: 'finished',
                    itemStyle: {
                        color: { // 完成的圆环的颜色
                            type: 'linear',
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [{
                                offset: 0, color:colors.color1||'#456FFB' // 0% 处的颜色
                            },{
                                offset: .5, color:colors.color2||'#456FFB' // 0% 处的颜色
                            }, {
                                offset: 1, color:colors.color2||'#456FFB' // 100% 处的颜色
                            }],
                            global: false
                        }           
                    }
                }, 
                {
                    name: 'unfinished',
                    value:100-data.value,
                    itemStyle:{
                        color:'rgba(42,69,136,1)'
                    }
                }
            ]
        }]
    };
    myChart.setOption(myOption, true)
    function formatData(){
        var data = [
            {
                value: 0,
                name: 'finished',
                itemStyle: {
                    color: { // 完成的圆环的颜色
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#2380FF' // 0% 处的颜色
                        },{
                            offset: .5, color: '#2380FF' // 0% 处的颜色
                        }, {
                            offset: 1, color: '#2380FF' // 100% 处的颜色
                        }],
                        global: false
                    }           
                }
            }, 
            {
                name: 'unfinished',
                value: 0,
                itemStyle:{
                    color:'#EBEFFA'
                }
            }
        ],title='';
        let percent = 0,total = 0,value = 0;
        if(typeof data == 'number'){
            value = Number(data);
            if(Math.abs(data)<1 && Math.abs(data)>0){
                total = 1;
                percent = data==0?0:(data*100).toFixed(2);
            }else if(Math.abs(data)<100 && Math.abs(data)>1){
                total = 100;
                percent = data==0?0:(data).toFixed(2);
            }
        }else{
            value = data.value-0;
            total = data.total-0||100;
            percent = value==0?0:(value/total * 100).toFixed(2);
        }
        title = percent + '%'+"\n完成率";
        data[0].value = value;
        data[1].value = total - value;
        console.log(data,"data")
        return {
            data: data,
            title: title
        };
    }
  }
    function setZBData(id,originalData,callback){
        var data = originalData||{};
        $(id+' [data-key]').each(function(i,ele){
            var key = $(this).attr('data-key');
            $(ele).html(data[key])
        })
        $(id+' .num').each(function(i,ele){
            $(this).rollNum({
                deVal: $(this).text() - 0,
                transToThursand: true
                // className:'my_scroll_num'
            });
        });
        callback && callback(data);
    }
    function setPie(id, data, option,clickFun) {
        var elem = $(id)[0];
        var myChart = echarts.getInstanceByDom(elem) || echarts.init(elem);
        var datas = data.datas;
        var maxNameLength = ((datas.map(item => {
            return item.name.length;
        })).sort(function (a, b) {
            return b - a;
        }))[0];
        var total = 0;
        datas.map(item => {
            total += item.value;
        })
       var series=[{
        type: "pie",
        radius: option.radius||['35%', '65%'],
        center: option.center||['20%', '50%'],
        roseType:option.roseType||false,
        name: data.name || '',
        label: {
            show: false
        },
        labelLine: {
            show: false
        },
        data: datas,
        hoverOffset:5,
        minAngle: 5 ,
        animation: true ,
    },]
     if(!option.normalPie){
        series.push({
            type: "pie",
            radius: option.radius2|| ['35%', '38%'],
            center: option.center||['20%', '50%'],
            name: '',
            label: {
                show: false
            },
            labelLine: {
                show: false
            },
            data: [{
                value: 1,
                itemStyle: {
                    color: '#fff'
                }
            }],
            hoverAnimation:false
        })
     }
        var myOption = {
            color: option.color || ['#2F9EFE', '#34C39D', '#FDAE5A', '#FF6169', '#8E67FF', '#89D47F'],
            grid: {
                left: 0,
                right: 0,
                top: 0,
                bottom: 0,
                containLabel: true,
            },
            tooltip:{
                show:true,
                formatter: '{b}<br />数值：{c}<br />占比：{d}%',
                confine: true,
                // padding:0
            },
            legend: {
                // type:datas.length>8?'scroll':'',
                orient: "vertical",
                type: option.type||'',
                top: option.legendTop||'middle',
                left: option.legendLeft || "40%",
                itemWidth: $$.transVHFontSize(1.5),
                itemHeight: $$.transVHFontSize(1.1),
                itemGap: option.legendItemGap || $$.transVHFontSize(.7),
                padding: 0,
                textStyle: {
                    fontSize: fontSize,
                    color: '#fff',
                    rich: {
                        name: {
                            fontSize: fontSize,
                            width: maxNameLength * $$.fitFontSize(18)
                        },
                        value: {
                            fontSize: fontSize,
                            color: '#fff'
                        },
                        percent: {

                        }
                    }
                },
                // formatter:datas.length>8?'{name}':
                formatter: function (name) {
                    var showValue = option.showValue || false,
                        showPercent = option.showPercent || false;
                    var index = datas.map(item => item.name).indexOf(name);
                    if (name && index > -1) {
                        var value = datas[index].value,
                            percent = (value / total * 100).toFixed(option.fixedNum || 2);
                        return [
                            '{name|' + name + '}',
                            showValue ? '{value|' + (value + (data.unit || '')) + '}' : '',
                            showPercent ? '{percent|' + (percent + '%') + '}' : '',
                        ].join('')
                    } else {
                        return name
                    }
                },
                pageIconSize: $$.transVHFontSize(1),
                pageIconColor: '#2f4554' ,
                pageIconInactiveColor: '#fff' ,
                pageTextStyle:{
                    fontSize: fontSize,
                    color: '#fff',
                }
            },
            series:series
            // series: [{
            //         type: "pie",
            //         radius: option.radius||['35%', '65%'],
            //         center: option.center||['20%', '50%'],
            //         roseType:option.roseType||false,
            //         name: data.name || '',
            //         label: {
            //             show: false
            //         },
            //         labelLine: {
            //             show: false
            //         },
            //         data: datas,
            //         hoverOffset:5,
            //         minAngle: 5 ,
            //         animation: true ,
            //     },
            //     {
            //         type: "pie",
            //         radius: ['35%', '38%'],
            //         center: option.center||['20%', '50%'],
            //         name: '',
            //         label: {
            //             show: false
            //         },
            //         labelLine: {
            //             show: false
            //         },
            //         data: [{
            //             value: 1,
            //             itemStyle: {
            //                 color: '#fff'
            //             }
            //         }],
            //         hoverAnimation:false
            //     },
            // ]
        }
        myChart.setOption(myOption, true);
        // myChart.off('click');
        // myChart.on('click',function(params){
        //     console.log(params,"puuu")
        //     // clickFun&& clickFun(params)
        // });
        myChart.off("legendselectchanged");
        myChart.on("legendselectchanged",function(params){
            var isSelected = params.selected[params.name];
            var title=params.name
            if(isSelected == false){
                myChart.dispatchAction({
                    type:'legendToggleSelect',
                    name: params.name
                });
                myChart.dispatchAction({
                    type:'highlight ',
                    name: params.name
                });
                clickFun&& clickFun(params)
            }
        });
    }
    function setRadar(id, data,total){
        var elem = $(id)[0];
        var myChart = echarts.getInstanceByDom(elem) || echarts.init(elem);
        var indicator = data.map(item=>{
            return {
                name: item.name+'('+(item.value||0)+')',
                max: 100
            }
        })
        var myOption = {
            // backgroundColor:'#000',
            title: {
                text: total||0,
                left:'center',
                top:'middle',
                textStyle:{
                        color:'#fff',
                        fontSize: $$.fitFontSize(36),
                        fontWeight:'bold'
                    }
            },
            legend:{
                show:false
            },
            radar: {
                shape: 'circle',
                radius: '50% ',
                indicator: indicator,
                name:{
                    textStyle:{
                        color:'#fff',
                        fontSize: $$.fitFontSize(18)
                    }
                },
                splitLine:{
                    lineStyle:{
                        color:'#8793a2',
                        type:'dotted'
                    }
                },
                axisLine:{
                    lineStyle:{
                        color:'#8793a2',
                        type:'dotted'
                    }
                },
                splitArea:{
                    show:false
                }
            },
            series: [{
                animation: true ,
                name: 'value',
                type: 'radar',
                data: [
                    {
                        value: data.map(item=>item.value),
                        name: '值'
                    }
                ],
                itemStyle:{
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#1673FF' // 0% 处的颜色
                        }, {
                            offset: 1, color: '#2FCAFD' // 100% 处的颜色
                        }],
                        global: false // 缺省为 false
                    }
                },
                lineStyle:{
                    width:4,
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#1673FF' // 0% 处的颜色
                        }, {
                            offset: 1, color: '#2FCAFD' // 100% 处的颜色
                        }],
                        global: false // 缺省为 false
                    }
                },
                areaStyle:{
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [{
                            offset: 0, color: '#4FB2F8' // 0% 处的颜色
                        }, {
                            offset: 1, color: '#1170C2' // 100% 处的颜色
                        }],
                        global: false // 缺省为 false
                    }
                }
            }]
        };
        myChart.setOption(myOption, true)
    }
    function setLine(id, data, option) {
        var elem = $(id)[0];
        var myChart = echarts.getInstanceByDom(elem) || echarts.init(elem);
        var datas = data.series,
            series = [],
            unit = data.unit;
        var color = option.color || ['rgba(72,182,255,1)', '#8E67FF', '#2F9EFE'];
        var chartType = '';
        datas.map((item, i) => {
            chartType = item.type||'line'
            series.push({
                animation: true ,
                name: item.name,
                stack: item.stack || '',
                type: item.type||'line',
                data: item.data,
                // symbol: 'circle',
                symbol: 'emptyCircle',
                symbolSize: 4,
                smooth: option.notSmooth?false:true,
                barWidth:10,
                lineStyle: {
                    width: 2,
                    color: color[i]
                },
                itemStyle: {
                    color: color[i]
                },
                areaStyle: {
                    show: option.hideArea?false:true,
                    color: color[i],
                    opacity: option.hideArea?0:.2
                },
                label:{
                    show:option.seriesLabel?true:false,
                    position:'top',
                    distance:1,
                    textStyle:{
                        color: color[i],
                        fontSize: fontSize-2
                    }
                }
            })
        })
        var myOption = {
            color: color,
            grid: {
                left:  '2%',
                right: '5%',
                top: $$.transVHFontSize(5),
                bottom: '0',
                containLabel: true,
            },
            legend: {
                show:true,
                orient: "horizontal",
                top: 'top',
                left:"center",
                itemWidth: $$.transVHFontSize(1.2),
                itemHeight: $$.transVHFontSize(.8),
                itemGap: $$.transVHFontSize(2),
                textStyle: {
                    fontSize: fontSize,
                    color: '#fff'
                }
            },
            tooltip: {
                show: true,
                trigger: "axis",
                // formatter:  (params)=> {// tooltip的formatter
                //     var relVal = params[0].name
                //     for (var i = 0, l = params.length; i < l; i++) {
                //       let settingUnit = this.option.setting[i].yAxisName;
                //       let unit = settingUnit || this.option.yAxis && this.option.yAxis[params[i].seriesIndex] && this.option.yAxis[params[i].seriesIndex].name || this.option.yAxisName;
                //         relVal += '<br/>' + params[i].marker + params[i].seriesName + ' : ' + params[i].value + (unit||'')
                //     }
                //     return relVal
                // }
            },
            xAxis: [{
                type: "category",
                show: true,
                interval: 0,
                boundaryGap:chartType=='bar'?true:false,
                axisLabel: {
                    show: true,
                    fontSize: fontSize,
                    color: "#fff",
                    interval: option.interval||0,
                    rotate: option.xAxisRotate||0,
                    formatter: option.xAxisOverflow?function(params){
                        return params.length>3?params.substr(0,2)+'...':params;
                        return params.split('').join('\n')
                    }:'{value}'
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#4F6776"
                    },
                },
                axisTick: {
                    show:  true,
                    lineStyle: {
                        color: "#4F6776",
                    },
                },
                splitLine: {
                    show: option["yAxisSplitLineShow"] || false,
                    lineStyle: {
                        type: "dotted",
                        width: 0.5,
                        color: "#4F6776",
                    },
                },
                data: data.categories,
            }, ],
            yAxis: {
                show: true,
                type: "value",
                name: unit ? '单位：' + unit : "",
                nameGap: $$.transVHFontSize(1),
                nameTextStyle: {
                    //   align: "right",
                    fontSize: fontSize,
                    color: "#fff",
                },
                axisLabel: {
                    show: true,
                    fontSize: fontSize,
                    color: "#fff",
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#4F6776"
                    },
                },
                axisTick: {
                    show:  true,
                    lineStyle: {
                        color: "#4F6776",
                    },
                },
                splitLine: {
                    show: option["yAxisSplitLineShow"] || false,
                    lineStyle: {
                        type: "dotted",
                        width: 0.5,
                        color: "#4F6776",
                    },
                },
            },
            series: series
        }
        myChart.setOption(myOption, true)
    }
    function setBar(id, data, option,clickFun) {
        var elem = $(id)[0];
        var myChart = echarts.getInstanceByDom(elem) || echarts.init(elem);
        var datas = data.series,
            series = [],
            unit = data.unit;
        var color = option.color || [
            {color2:'#ACCBFF',color1:'#2F9EFE'},
            {color2:'#ACCBFF',color1:'#2FFEAE'},
            {color2:'#ACCBFF',color1:'#FE9F2F'},
        ];
        var chartType = '';
        console.log(option.stack,"stack")
        datas.map((item, i) => {
            chartType = item.type||'line'
            series.push({
                animation: true ,
                name: item.name,
                stack: option.stack|| '',
                type: 'bar',
                data: item.data,
                barWidth:18,
                itemStyle: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: color[i].color1
                        },
                        {
                            offset: 1,
                            color: color[i].color2
                        }
                    ])
                },
                label:{
                    show:option.showLable||false,
                    position:'top',
                    distance:1,
                    textStyle:{
                        color: color[i],
                        fontSize: $$.fitFontSize(16)
                    }
                }
            })
        })
        var myOption = {
            color: color,
            grid: {
                left:  '1%',
                right: 0,
                top: unit ? $$.transVHFontSize(4.5) : 0,
                bottom: '0',
                containLabel: true,
            },
            legend: {
                show: series.length==1?false:true,
                orient: "horizontal",
                top: 'top',
                left: "center",
                itemWidth: $$.transVHFontSize(1.2),
                itemHeight: $$.transVHFontSize(.8),
                itemGap: $$.transVHFontSize(2),
                textStyle: {
                    fontSize: fontSize,
                    color: '#fff'
                }
            },
            tooltip: {
                show: true,
                trigger: "axis",
                formatter: '{b}<br />数值：{c}',
                // formatter:  (params)=> {// tooltip的formatter
                //     var relVal = params[0].name
                //     for (var i = 0, l = params.length; i < l; i++) {
                //       let settingUnit = this.option.setting[i].yAxisName;
                //       let unit = settingUnit || this.option.yAxis && this.option.yAxis[params[i].seriesIndex] && this.option.yAxis[params[i].seriesIndex].name || this.option.yAxisName;
                //         relVal += '<br/>' + params[i].marker + params[i].seriesName + ' : ' + params[i].value + (unit||'')
                //     }
                //     return relVal
                // }
            },
            xAxis: [{
                type: "category",
                show: true,
                interval: 0,
                boundaryGap:true,
                axisLabel: {
                    show: true,
                    fontSize: fontSize,
                    color: "#fff",
                    interval: option.interval||0,
                    rotate: option.xAxisRotate||0,
                    formatter: option.xAxisOverflow?function(params){
                        return params.length>3?params.substr(0,2)+'...':params;
                        return params.split('').join('\n')
                    }:'{value}'
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: "#4F6776"
                    },
                },
                axisTick: {
                    show:  true,
                    lineStyle: {
                        color: "#4F6776",
                    },
                },
                splitLine: {
                    show: option["yAxisSplitLineShow"] || false,
                    lineStyle: {
                        type: "dotted",
                        width: 0.5,
                        color: "#4F6776",
                    },
                },
                data: data.categories,
            }, ],
            yAxis: [
                {
                    show: true,
                    type: "value",
                    name: unit ? '单位：' + unit : "",
                    nameGap: $$.transVHFontSize(1.5),
                    nameTextStyle: {
                        //   align: "right",
                        fontSize: fontSize,
                        color: "#fff",
                    },
                    axisLabel: {
                        show: true,
                        fontSize: fontSize,
                        color: "#fff",
                    },
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: "#4F6776"
                        },
                    },
                    axisTick: {
                        show:  true,
                        lineStyle: {
                            color: "#4F6776",
                        },
                    },
                    splitLine: {
                        show: option["yAxisSplitLineShow"] || false,
                        lineStyle: {
                            type: "dotted",
                            width: 0.5,
                            color: "#4F6776",
                        },
                    },
                },
            ],
            series: series
        }
        myChart.setOption(myOption, true)
        myChart.off('click').on("click",function(params){
            clickFun&&clickFun(params)
        })
    }
})